package com.ops.memcache.utility;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Properties;

public class EnvironmentConfig {
  static EnvironmentConfig ec;
  private static Hashtable<String, Properties> register = new Hashtable();

  private EnvironmentConfig() {
  }

  public static EnvironmentConfig getInstance() {
    if(ec == null) {
      ec = new EnvironmentConfig();
    }

    return ec;
  }

  public Properties getProperties(String fileName) {
    Object is = null;
    Properties p = null;

    try {
      p = (Properties)register.get(fileName);
      if(p == null) {
        try {
          is = new FileInputStream(fileName);
        } catch (Exception var5) {
          if(fileName.startsWith("/")) {
            is = EnvironmentConfig.class.getResourceAsStream(fileName);
          } else {
            is = EnvironmentConfig.class.getResourceAsStream("/" + fileName);
          }
        }

        p = new Properties();
        p.load((InputStream)is);
        register.put(fileName, p);
        ((InputStream)is).close();
      }
    } catch (Exception var6) {
      var6.printStackTrace(System.out);
    }

    return p;
  }

  public String getPropertyValue(String fileName, String strKey) {
    Properties p = this.getProperties(fileName);

    try {
      return p.getProperty(strKey);
    } catch (Exception var5) {
      var5.printStackTrace(System.out);
      return null;
    }
  }
}
